﻿<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%
    
         //Response.ContentType = "text/xml";
        OleDbConnection conn = null;
        try
        {
            conn = DBOp.DbConn; 
            OleDbCommand comm = conn.CreateCommand();
            String where = Request.Params["where"];
            where = string.IsNullOrEmpty(where) ? "" : where;
            where = string.IsNullOrEmpty(where.Trim()) ? " where 建筑年平均耗电量 is not null and 建筑年单位面积能耗 < 300" : " where 建筑年平均耗电量 is not null  and 建筑年单位面积能耗 < 300 and " + where.Trim() + " ";
            comm.CommandText = "select sum(m01)/sum(t2.建筑面积),sum(m02)/sum(t2.建筑面积),sum(m03)/sum(t2.建筑面积),sum(m04)/sum(t2.建筑面积),sum(m05)/sum(t2.建筑面积),sum(m06)/sum(t2.建筑面积),sum(m07)/sum(t2.建筑面积),sum(m08)/sum(t2.建筑面积),sum(m09)/sum(t2.建筑面积),sum(m10)/sum(t2.建筑面积),sum(m11)/sum(t2.建筑面积),sum(m12)/sum(t2.建筑面积),year  from 建筑用电电量总表 t1 left join jz t2 on t1.建筑统一编码 = t2.建筑统一编码 " + where + "  group by t1.year order by t1.year";
            OleDbDataReader reader = comm.ExecuteReader();
                // xAxisName='月份'
                %>
                <chart caption='月单位面积能耗统计' subcaption='( 单位：千瓦时/平方米)' legendPosition='right' labelDisplay='ROTATE' slantLabels='1' yAxisName='单位面积用电量' formatNumberScale='0' baseFontSize='12' baseFontFamily='宋体' numberPrefix='' showValues='0' alternateHGridColor='FCB541' alternateHGridAlpha='20' divLineColor='FCB541' divLineAlpha='50' canvasBorderColor='666666' baseFontColor='666666' lineColor='FCB541'>
                <categories>

                <category label='一月' />
                <category label='二月' />
                <category label='三月' />
                <category label='四月' />
                <category label='五月' />
                <category label='六月' />
                <category label='七月' />
                <category label='八月' />
                <category label='九月' />
                <category label='十月' />
                <category label='十一月' />
                <category label='十二月' />
                </categories>

                <%
int j = 0;
            while(reader.Read()){  
                
                    j++;
                  String color = "FF00FF";
                  if(j == 2){
                    color = "1D8BD1";
                  }
                  else if(j==3){
                      color = "483D8B";
                  }
                  else if (j == 4)
                  {
                      color = "800080";
                  }
                  else if (j == 5)
                  {
                      color = "AFEEEE";
                  }
                %>
                <dataset seriesName='<%=reader.GetValue(12) %>年' color='<%=color %>' anchorBorderColor='<%=color %>' anchorBgColor='<%=color %>'>
                <% for (int i = 0; i < 12; i++)
                   {
                       double value = 0;
                       try
                       {
                           value = reader.GetDouble(i);
                       }
                       catch { }
                       int a = i - 1 >= 0 ? i - 1 : i;
                       double value1 = 0;
                       double value2 = 0;
                       try {
                           value1 = reader.GetDouble(a);                          
                       }
                       catch { }
                       try
                       {
                           value1 = reader.GetDouble(i + 1);

                       }
                       catch { }
                       if (value == 0)
                           value = (value1 + value2)/2;
                       %><set value='<%=value.ToString() %>' />
                   <%} %>
                </dataset>
                  <%} %>
                <styles><definition>  <style name='Anim1' type='animation' param='_xscale' start='0' duration='1' />   <style name='Anim2' type='animation' param='_alpha' start='0' duration='0.6' />   <style name='DataShadow' type='Shadow' alpha='40' />   </definition><application>  <apply toObject='DIVLINES' styles='Anim1' />   <apply toObject='HGRID' styles='Anim2' />   <apply toObject='DATALABELS' styles='DataShadow,Anim2' />   </application>  </styles>  </chart>
                <%
            }
            catch(Exception ex){}
                    finally{
                        if (conn != null)
                            conn.Close();
        }
                        %>
